<html>
<head><meta charset="utf-8"><title>Arc::make_mut for Arc&lt;[T]&gt;? · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Arc.3A.3Amake_mut.20for.20Arc.3C.5BT.5D.3E.3F.html">Arc::make_mut for Arc&lt;[T]&gt;?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="217584308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Arc%3A%3Amake_mut%20for%20Arc%3C%5BT%5D%3E%3F/near/217584308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Peter Rabbit <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Arc.3A.3Amake_mut.20for.20Arc.3C.5BT.5D.3E.3F.html#217584308">(Nov 23 2020 at 02:52)</a>:</h4>
<p>Would it be possible to enable <code>Arc::make_mut</code> for <code>Arc&lt;[T]&gt;</code> and similar for <code>Rc</code>? I know <code>Box&lt;[T]&gt;</code> is <code>Clone</code> which is a somewhat similar situation.</p>



<a name="217686239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Arc%3A%3Amake_mut%20for%20Arc%3C%5BT%5D%3E%3F/near/217686239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Arc.3A.3Amake_mut.20for.20Arc.3C.5BT.5D.3E.3F.html#217686239">(Nov 23 2020 at 21:40)</a>:</h4>
<p>sounds like that could be useful :)</p>



<a name="217704227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Arc%3A%3Amake_mut%20for%20Arc%3C%5BT%5D%3E%3F/near/217704227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Arc.3A.3Amake_mut.20for.20Arc.3C.5BT.5D.3E.3F.html#217704227">(Nov 24 2020 at 01:11)</a>:</h4>
<p>I think it has to be a separate block:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">Clone</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Rc</span><span class="o">&lt;</span><span class="p">[</span><span class="n">T</span><span class="p">]</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">make_mut</span><span class="p">(</span><span class="n">_this</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="bp">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">todo</span><span class="o">!</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="217704243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Arc%3A%3Amake_mut%20for%20Arc%3C%5BT%5D%3E%3F/near/217704243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Arc.3A.3Amake_mut.20for.20Arc.3C.5BT.5D.3E.3F.html#217704243">(Nov 24 2020 at 01:11)</a>:</h4>
<p>but the compiler does accept this much</p>



<a name="217704307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Arc%3A%3Amake_mut%20for%20Arc%3C%5BT%5D%3E%3F/near/217704307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Arc.3A.3Amake_mut.20for.20Arc.3C.5BT.5D.3E.3F.html#217704307">(Nov 24 2020 at 01:12)</a>:</h4>
<p>that surprises me a little, because it seems to rely on proving that the other <code>impl&lt;T: Clone&gt; Rc&lt;T&gt;</code> doesn't apply, i.e. <code>[T]: !Clone</code></p>



<a name="217704322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Arc%3A%3Amake_mut%20for%20Arc%3C%5BT%5D%3E%3F/near/217704322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Arc.3A.3Amake_mut.20for.20Arc.3C.5BT.5D.3E.3F.html#217704322">(Nov 24 2020 at 01:13)</a>:</h4>
<p>which is true, but I didn't think the compiler would allow that by coherence</p>



<a name="217704614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Arc%3A%3Amake_mut%20for%20Arc%3C%5BT%5D%3E%3F/near/217704614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Arc.3A.3Amake_mut.20for.20Arc.3C.5BT.5D.3E.3F.html#217704614">(Nov 24 2020 at 01:19)</a>:</h4>
<p>oh, that's probably because <code>[T]</code> is unsized, so it can never add <code>Clone</code>... ok, don't worry about my tangent</p>



<a name="217714701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Arc%3A%3Amake_mut%20for%20Arc%3C%5BT%5D%3E%3F/near/217714701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Arc.3A.3Amake_mut.20for.20Arc.3C.5BT.5D.3E.3F.html#217714701">(Nov 24 2020 at 04:54)</a>:</h4>
<p><code>impl&lt;T: Clone&gt; Rc&lt;T&gt;</code> does not apply not because of <code>[X]: !Clone</code>, but <code>[X]: !Sized</code> and there is an implicit <code>Sized</code> bound</p>



<a name="217714758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Arc%3A%3Amake_mut%20for%20Arc%3C%5BT%5D%3E%3F/near/217714758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Arc.3A.3Amake_mut.20for.20Arc.3C.5BT.5D.3E.3F.html#217714758">(Nov 24 2020 at 04:56)</a>:</h4>
<p>and if <a href="https://github.com/rust-lang/rfcs/issues/2884">rfc#2884</a> is approved, it is possible to return <code>[X]</code> from a function and thus <code>impl&lt;X: Clone&gt; Clone for [X]</code> may be acceptable</p>



<a name="217771475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Arc%3A%3Amake_mut%20for%20Arc%3C%5BT%5D%3E%3F/near/217771475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Arc.3A.3Amake_mut.20for.20Arc.3C.5BT.5D.3E.3F.html#217771475">(Nov 24 2020 at 15:47)</a>:</h4>
<p>Ah, right, it's not because of <code>Clone: Sized</code>, but all <code>impl&lt;T&gt;</code> implies <code>T: Sized</code> by default.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>